$(document).ready(
	function() {
		
	}
);

function delete_banner(banner_id) {
	if(confirm('Are you sure you want to delete this banner?')) {
		$.post('/admin/banners_ajax/delete_banner', {'banner_id' : banner_id}, function(d){
			if(d.deleted) {
				$('#banner_wrapper_'+banner_id).remove();
			}
		}, 'json')
	}
}

function open_media_manager() {
	create_overlay(null, function(sId, oImg, oParams) {
		create_popup('pages_media', 'pages_media_overlay', 760, 560, 'Select media', '/admin/media/popup/banner_insert_media', function() {
			$(oImg).remove();
			$('#' + sId).remove();
			$('#pages_media_overlay').show();
		});
	}, {});
}

function banner_insert_media(oObj, iMediaId) {
	$.post('/admin/media_ajax/get_media_props', { iMediaId : iMediaId }, function(data) {
		
		if (data.extension_thumb === 'Y') {
			var sSrc = '/assets/media/web/' + data.media_subfolder + '/' + data.media_id + '.' + data.extension_ext;
			
			$('#banner_image').val(data.media_id);
			
			$('#image_wrapper').html('<img src="'+sSrc+'" />');
			
			$('#pages_media_overlay').remove();
		} else {
			
			alert('Please select an image.');
		
		}
	}, 'json');
}